#!/bin/sh

#################################
#安装svn同步client需要的软件包
#使用makeself.sh打包 wget http://www.megastep.org/makeself/makeself-2.1.5.run
#  makeself.sh rs_client_install rsync_client_install "rsync client agent install" ./install.sh
#################################

#安装python开发包和gcc
for pkg in python-devel python-setuptools gcc
do
	cmd=$(rpm -q $pkg)
	#未安装包
	if [ $? -eq 1 ]
	then
		yum install python-devel python-setuptools gcc -y
	fi
done

for pkg in python-devel python-setuptools gcc
do
	cmd=$(rpm -q $pkg)
	#未安装包
	if [ $? -eq 1 ]
	then
		echo ""
		echo "install fail"
		exit
	fi
done

ROOT_DIR=$(pwd)

cd $ROOT_DIR

mkdir -p /data/app/rsync
mkdir -p /data/app/rsync/bin

#解压所有的软件包
tar -zxf zope.interface-3.5.3.tar.gz && tar -jxf Twisted-11.0.0.tar.bz2 && tar -zxf meld3-0.6.10.tar.gz && tar -zxf supervisor-3.0.tar.gz && unzip -oq elementtree-1.2.7-20070827-preview.zip 

cd $ROOT_DIR/zope.interface-3.5.3 && python setup.py install
cd $ROOT_DIR/Twisted-11.0.0 && python setup.py install
cd $ROOT_DIR/meld3-0.6.10 && python setup.py install
cd $ROOT_DIR/elementtree-1.2.7-20070827-preview && python setup.py install
cd $ROOT_DIR/supervisor-3.0 && sed -i "71d" setup.py && python setup.py install

cp -ra $ROOT_DIR/rs_client.py /data/app/rsync
cp -ra $ROOT_DIR/supervisord.conf /data/app/rsync
cp -ra $ROOT_DIR/resin_lbfont.sh /data/app/bin
cp -ra $ROOT_DIR/tomcat_gblinkbusiness.sh /data/app/bin
cp -ra $ROOT_DIR/tomcat_game_boss.sh /data/app/bin

#echo "supervisord -c /data/app/rsync/supervisord.conf"
supervisord -c /data/app/rsync/supervisord.conf

echo ""
echo ""
echo "install success"
